﻿using netDxf;
using netDxf.Entities;
using netDxf.Header;
using netDxf.Tables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestDxfDocument

{
    class ISYC_309_06
    {
        //图F.97  ISYC 309-06-可转位刀片柄连接背镗杆
        public static void ISYC_309_06_g(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //基本参数-------------------------------------------------------------------------------------------------
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            //赋值参数--------------------------------------------------------------------------------------------------
            double sl_ = Convert.ToDouble(data["oal"]);
            double scale = Convert.ToDouble(data["scale"]);
         //   double sl_ = 120;
         //   double scale = 1;
            if (sl_ <= 67)
            {
                scale = 4;
            }
            else if (67 < sl_ && sl_ <= 75)
            {
                scale = 2.5;
            }
            else if (75 < sl_ && sl_ <= 100)
            {
                scale = 2;
            }
            else
            {
                scale = 1;
            }/*
            double dconms = 10 * scale;
            double oal = 46.75 * scale;
            double lf = 36.25 * scale;
            double lh = 13.03 * scale;
            double lpr = 23.37 * scale;
            double lta = 14.91 * scale;
            double wf = 18.55 * scale;
            double kapr = 103;
            double kapr_ = kapr * pi / 180;
            double dp_ = 40*pi/180;
            */
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double lf = Convert.ToDouble(data["lf"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double lpr = Convert.ToDouble(data["lpr"]) * scale;
            double lta = Convert.ToDouble(data["lta"]) * scale;
            double wf = Convert.ToDouble(data["wf"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]);
            double kapr_ = kapr * pi / 180;
            double dp_ = 40 * pi / 180;
            //点---------------------------------------------------------------------------------------------
            //第一部分

            Vector2[] Noncutting(Vector2 p)
            {
                Vector2 p0_1; Vector2 p0_2; Vector2 p1; Vector2 p2; Vector2 p3; Vector2 p4;
                p0_1 = fun.Polar(p, pi, oal - lh + 5);
                p0_2 = fun.Polar(p, 0, lh + 5);
                p1 = fun.Polar(p, pi / 2, dconms / 2.0);
                p2 = fun.Polar(p1, pi / -2, dconms ) ;
                p3 = fun.Polar(p1, pi, oal - lh);
                p4 = fun.Polar(p3, pi / -2, dconms) ;
                var polyline1 = Pus.AddPointsToLwPolyLine(p1, p2, p4, p3, p1);

                Line line1 = new Line(p0_1, p0_2);
                line1.Lineweight = Lineweight.W25;//Lineweight指线宽
                line1.Layer = centre ;//Layer指图层
                line1.LinetypeScale = 5 * scale;//指线性比例
                line1.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
                fun.PolyFill(dxf, polyline1, 0.5, contour);
               dxf.AddEntity(new EntityObject[] {  line1 });
                Vector2[] pf = new Vector2[] { p1, p2, p3, p4 ,p0_1 ,p0_2 };
                return  pf ;
            }
            Vector2 p0 = new Vector2(0, 0);
            Vector2[] pj = Noncutting(p0);
            Vector2 p1_0 = pj[0];
            Vector2 p5 = fun.Polar(p1_0, pi / -2, dconms * (0.32 / 6.18));
            Vector2 p6 = fun.Polar(p5, 0, lta / 62.0);
            Vector2 p7 = new Vector2(lh - lpr + lta, 0);
            Vector2 p8 = fun.Polar(p7, 0, lpr - lta);
            Vector2 p9 = fun.Polar(p8, pi / -2, dconms / 2.0 - dconms / 21.0);
            Vector2 p10 = fun.Polar(p9, pi, lh);
            Vector2 p11 = fun.Polar(p7, 0, (6.5 / 13.2) * lh);
            Vector2 p12 = fun.Polar(p7, pi / -2, -(p9.Y - p7.Y) / 4.36);
            Vector2 p13 = fun.Polar(p12, 0, fun.CalDistance(p7, p11));
            Vector2 p14 = fun.Polar(p12, 0, (0.4 / 6.5) * fun.CalDistance(p7, p11));
            Vector2 p15 = fun.Polar(p13, pi, fun.CalDistance(p12, p14));
            Vector2 p16_0 = fun.Polar(p14, pi / -2, dconms);
            Vector2 p16 = fun.Inters(p14, p16_0, p10, p9);
            Vector2 p17_0 = fun.Polar(p15, pi / -2, dconms);
            Vector2 p17 = fun.Inters(p15, p17_0, p10, p9);

            Vector2 p0_4 = new Vector2(0, -dconms * 3);
            Vector2[] pj1 = Noncutting(p0_4);
            Vector2 p1_1 = pj1[0];
            Vector2 p18 = fun.Polar(p1_1, 0, lh / 2.3);
            Vector2 p19_1 = fun.Polar(p1_1, 0, lh);
            Vector2 p19_2 = fun.Polar(p19_1, pi / 2, lh);
            Vector2 p19 = fun.Inters(p19_1, p19_2, p18, fun.Polar(p18, pi / -6, lh));
            Vector2 p20 = fun.Polar(p1_1, pi / -2, dconms - dconms * (0.32 / 6.18));
            Vector2 p21_1 = fun.Polar(p18, pi / -2, lh);
            Vector2 p21_2 = fun.Polar(p20, 0, lh);
            Vector2 p21 = fun.Inters(p20, p21_2, p18, p21_1);
            Vector2 p22 = new Vector2(lh - (oal - lf), -wf + p1_1.Y - dconms / 2.0);
            Vector2 p23_1 = fun.Polar(p19, pi, dconms * (0.32 / 6.18));
            Vector2 p23_2 = fun.Polar(p23_1, pi / -2, lh * 2);
            Vector2 p23 = fun.Inters(p23_1, p23_2, p22, fun.Polar(p22, pi - kapr_ - dp_ /2, lh*2));
            Vector2 p24 = fun.Polar(p22, pi - kapr_, (fun.CalDistance(p22, p23) / 2.0) / Math.Cos(pi / 6 / 2));
            Vector2 p25 = fun.Polar(p22, pi - kapr_ -dp_ , fun.CalDistance(p22, p24));
            Vector2 p26 = fun.Polar(p25, fun.CalAngle(p25, p23), fun.CalDistance(p25, p23) / 5.0);
            Vector2 p27_0 = fun.Polar(p26, 40 * pi / 180, lh);
            Vector2 p27 = fun.Inters(p26, p27_0, p19, fun.Polar(p19, pi / -2, lf));
            Vector2 p28 = fun.Inters(p24, p23, p21, fun.Polar(p21, pi / -2, lh));
            Vector2 p29 = fun.Polar(p22, fun.CalAngle(p22, p23), fun.CalDistance(p22, p23) / 4.0);
            Vector2 p30 = fun.Polar(p24, fun.CalAngle(p24, p25), fun.CalDistance(p24, p25) / 4.0);
            Vector2 p31 = fun.Polar(p23, fun.CalAngle(p23, p22), fun.CalDistance(p22, p29));
            Vector2 p32 = fun.Polar(p25, fun.CalAngle(p25, p24), fun.CalDistance(p24, p30));
            Vector2 p33 = fun.Polar(p1_1, 0, fun.CalDistance(p1_1, p18) / 3.0);
            Vector2 p34 = fun.Polar(p20, 0, fun.CalDistance(p20, p21) / 4.0);
            Arc arc2 = fun.DrawArc5(p33, new Line(p1_1, p20), p34);
            Vector2 arc1_1 = fun.Polar(p7, pi / -2, 0.01);
            Vector2 arc1_2 = fun.Polar(arc1_1, pi, lh);
            Arc arc1 = fun.DrawArc5(p6, new Line(arc1_1, arc1_2), p7);
            var polyline2 = Pus.AddPointsToLwPolyLine(p6, p5, p10, p16, p14, p12, p7, p11, p13, p14, p16, p17,
                p15, p17, p9, p8, p7);
            var polyline3 = Pus.AddPointsToLwPolyLine(p20, p21, p28, p24, p22, p25, p23, p24, p22, p25, p26, p27, p19, p18, p1_1) ;
            var polyline4 = Pus.AddPointsToLwPolyLine(p29, p30, p31, p32, p29);
           /* dxf.AddEntity(new EntityObject[] { arc1,arc2
                , polyline2,polyline3 ,polyline4 
            });*/
            fun.PolyFill(dxf, polyline2, 0.5, contour);
            fun.PolyFill(dxf, polyline3, 0.5, contour);
            fun.PolyFill(dxf, polyline4, 0.5, contour);
            fun.drawBArc(dxf, arc1, 0.5, contour);
            fun.drawBArc(dxf, arc2, 0.5, contour);
            //标注
            Vector2 v1 = fun.Polar(p0, pi, lpr - lh);
            Vector2 v2 = pj1[2];//2,p3
            Vector2 v3 = pj1[3];//2,p4
            Vector2 v4 = pj1[5];//2,p0_2
            Vector2 v5 = fun.Polar(p0, pi, oal - lh);//1图,坐标
            Vector2 v6 = fun.Polar(p7, pi, lta);
            Vector2 v7 = fun.Polar(p7, 0, fun.CalDistance(p7, p11) / 2.0);
            Vector2 v8 = fun.Polar(v5, pi / -2, dconms * 3);//2图,坐标
            Vector2 v9 = fun.Polar(v6, pi / -2, dconms * 3);
            Vector2 v10 = fun.Inters(p24, p25, p22, p23);
            Vector2 v11 = fun.Polar(p7, pi - pi/3, 0.5 * 1.7 * scale) ;//圆
            Vector2 v12 = fun.Polar(v7, pi / 6, 0.5 * 1.7 * scale);
            Vector2 v13 = fun.Polar(v5, pi + 80 * pi / 180, 0.5 * 1.7 * scale);
            Vector2 v14 = fun.Polar(v13, pi + 80 * pi / 180, (fun.CalDistance(v5, v8) / 2.0) / Math.Cos(10 * pi / 180));
            Vector2 v15 = fun.Polar(v8, pi / 2 + 10 * pi / 180, 0.5 * 1.7 * scale);
            Vector2 v16 = fun.Polar(v14, pi / -2, 1.2 * scale);
            Vector2 v17 = fun.Polar(v6, pi + 80 * pi / 180, 0.5 * 1.7 * scale);
            Vector2 v18 = fun.Polar(v17, pi + 80 * pi / 180, (fun.CalDistance(v5, v8) / 2.0) / Math.Cos(10 * pi / 180));
            Vector2 v19 = fun.Polar(v9, pi / 2 + 10 * pi / 180, 0.5 * 1.7 * scale);
            Vector2 v20 = fun.Polar(v18, pi / -2, 1.2 * scale);
            Vector2 v21 = fun.Polar(v10, -70 * pi / 180, 0.5 * 1.7 * scale);
            Vector2 v22 = fun.Polar(v21, -70 * pi / 180, dconms);
            Vector2 v23 = fun.Polar(p22, pi + pi / 4, 0.5 * 1.7 * scale);
            Vector2 v24 = fun.Polar(v23, pi + pi / 4, dconms/2.0);

            fun.dimrot1(dxf, v1, p7, 0, dconms , 2, 1.2 * scale, 1.6 * scale, 0.9, "LTA", "", "");
            fun.dimrot1(dxf, v1, p8, 0, dconms*1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "LPR", "", "");
            fun.dimrot1(dxf, v2, v3, 90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCONMS", "", "");
            fun.dimrot1(dxf, p1_1 , p19, 0, dconms/2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "LH", "", "");
            fun.dimrot1(dxf,v4 , p22, -90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "WF,WTA", "", "");
            fun.dimrot1(dxf, v3, p22, 180, dconms*1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "LF", "", "");
            fun.dimrot1(dxf, v3, p27, 180, dconms*2.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL", "", "");
            fun.dimrot1(dxf, p7, fun .Polar (p8,pi/-2,0.01), -90, dconms *1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "HTA,HF", "", "");
            fun.jdbz2(dxf, new Line(p22,p24 ), new Line(p22, fun.Polar(p22, pi, 0.1)), wf/2.0  , 1.2 * scale, 1.6 * scale, 0.9, "KAPR", "", "");
            fun.Axis(dxf, v5 , 180, 90, "Z", "Y", "", 0.5 * scale, 1.6 * scale, 0);
            fun.Axis(dxf, v6, 180, 90, "Z", "Y", "", 0.5 * scale, 1.6 * scale, 0);
            fun.Axis(dxf, v7, 0, 90, "Y", "Z", "", 0.5 * scale, 1.6 * scale, 0);
            fun.Axis(dxf, v8, 180, -90, "Z", "X", "", 0.5 * scale, 1.6 * scale, 0);
            fun.Axis(dxf, v9, 180, -90, "Z", "X", "", 0.5 * scale, 1.6 * scale, 0);
            fun.Axis(dxf, v10, fun.CalAngle(v10, p25) * 180 / pi + 10, fun .CalAngle (v10,p22)*180/pi+9, "Y", "X", "", 0.5 * scale, 1.6 * scale, 0);
            Circle circlev1 = new Circle(p7, 1.7 *0.5 * scale);
            Circle circlev2 = new Circle(p22, 1.7 * 0.5 * scale);
            Line linev1 = new Line(v11, fun.Polar(v11, pi - 70 * pi / 180, dconms / 2.0));
            Line linev2 = new Line(v12, fun.Polar(v12, pi/6, dconms / 2.0));
            Line linev3 = new Line(v13, v14);
            Line linev4 = new Line(v15, v16);
            Line linev5 = new Line(v17, v18);
            Line linev6 = new Line(v19, v20);
            Line linev7 = new Line(v21, v22);
            Line linev8 = new Line(v23, v24);
            Text txt1 = new Text("CRP", fun.Polar(v11, pi - 50*pi/180, dconms / 1.8), 1.2 * scale, 0);
            Text txt2 = new Text("CSW", fun.Polar(v12, pi / 6, dconms / 1.7), 1.2 * scale, 0);
            Text txt3 = new Text("PCS", fun.Polar(v14, pi / -2, 1.2*scale ), 1.2 * scale, 0);
            Text txt4 = new Text("MCS", fun.Polar(v18, pi / -2, 1.2 * scale), 1.2 * scale, 0);
            Text txt5 = new Text("CSW", fun.Polar(v22, pi / -2, 1.2 * scale), 1.2 * scale, 0);
            Text txt6 = new Text("CRP", fun.Polar(v24, pi / -2, 1.2 * scale), 1.2 * scale, 0);
            Text txt7 = new Text("ISYC=309_06", fun.Polar(v6, pi / 2, dconms *2), 1.2 * scale, 0);

            dxf.AddEntity(new EntityObject[] {circlev1 ,circlev2
            ,linev1 ,linev2 ,linev3 ,linev4 ,linev5 ,linev6,linev7 ,linev8 
            ,txt1 ,txt2 ,txt3 ,txt4,txt5,txt6 ,txt7 
            });
            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
}
        //图F.97  ISYC 309-06-可转位刀片柄连接背镗杆
        public static void ISYC_309_06_j(Dictionary<string, Object> data)
        {
            DxfDocument dxf = new DxfDocument();
            //图层
            Layer contour = new Layer("contour") { Color = AciColor.Cyan };    //轮廓层
            Layer dimensioning = new Layer("dimensioning");    //尺寸层
            Layer refin = new Layer("refin") { Color = AciColor.Red };    //基准线/内轮廓
            Layer centre = new Layer("centre") { Color = AciColor.Yellow };    //中性线
            Layer textlayer = new Layer("textlayer") { Color = AciColor.Blue };    //文本层
            Layer hatching = new Layer("hatching") { Color = AciColor.Blue };    //填充层
            Layer additionalline = new Layer("additionalline") { Color = AciColor.Cyan };    //附加线
            Layer cutting = new Layer("cutting") { Color = AciColor.Red };    //切削层
            Layer nocutting = new Layer("nocutting");    //非切削层
            Layer skcontour = new Layer("skcontour") { Color = AciColor.Cyan };    //sk轮廓层
            Layer skdimensioning = new Layer("skdimensioning");    //sk尺寸线层
            Layer skrefin = new Layer("skrefin") { Color = AciColor.Red };    //sk基准线/内轮廓
            Layer sktext = new Layer("sktext") { Color = AciColor.Blue };  //sk文本
            Layer skhatching = new Layer("skhatching") { Color = AciColor.Blue };    //sk填充
            Layer skadditionlline = new Layer("skadditionlline") { Color = AciColor.Cyan };    //sk附加线
            Layer skviewcontour = new Layer("skviewcontour") { Color = AciColor.Cyan };    //skview轮廓
            Layer skviewdimensioning = new Layer("skviewdimensioning");    //skview尺寸线层

            //基本参数-------------------------------------------------------------------------------------------------
            double pi = Math.PI;
            string path = Convert.ToString(data["path"]);

            //赋值参数--------------------------------------------------------------------------------------------------
             double sl_ = Convert.ToDouble(data["oal"]);
             double scale = Convert.ToDouble(data["scale"]);
          //  double sl_ = 120;
          //  double scale = 1;
            if (sl_ <= 67)
            {
                scale = 4;
            }
            else if (67 < sl_ && sl_ <= 75)
            {
                scale = 2.5;
            }
            else if (75 < sl_ && sl_ <= 100)
            {
                scale = 2;
            }
            else
            {
                scale = 1;
            }/*
            double dconms = 10 * scale;
            double oal = 46.75 * scale;
            double lf = 36.25 * scale;
            double lh = 13.03 * scale;
            double lpr = 23.37 * scale;
            double lta = 14.91 * scale;
            double wf = 18.55 * scale;
            double kapr = 103;
           
            */
            double dconms = Convert.ToDouble(data["dconms"]) * scale;
            double oal = Convert.ToDouble(data["oal"]) * scale;
            double lf = Convert.ToDouble(data["lf"]) * scale;
            double lh = Convert.ToDouble(data["lh"]) * scale;
            double lpr = Convert.ToDouble(data["lpr"]) * scale;
            double lta = Convert.ToDouble(data["lta"]) * scale;
            double wf = Convert.ToDouble(data["wf"]) * scale;
            double kapr = Convert.ToDouble(data["kapr"]);
            double kapr_ = kapr * pi / 180;
            double dp_ = 40 * pi / 180;
            //点---------------------------------------------------------------------------------------------
            //第一部分

            Vector2[] Noncutting(Vector2 p)
            {
                Vector2 p0_1; Vector2 p0_2; Vector2 p1; Vector2 p2; Vector2 p3; Vector2 p4;
                p0_1 = fun.Polar(p, pi, oal - lh + 5);
                p0_2 = fun.Polar(p, 0, lh + 5);
                p1 = fun.Polar(p, pi / 2, dconms / 2.0);
                p2 = fun.Polar(p1, pi / -2, dconms);
                p3 = fun.Polar(p1, pi, oal - lh);
                p4 = fun.Polar(p3, pi / -2, dconms);
                var polyline1 = Pus.AddPointsToLwPolyLine(p1, p2, p4, p3, p1);

                Line line1 = new Line(p0_1, p0_2);
                line1.Lineweight = Lineweight.W25;//Lineweight指线宽
                line1.Layer = centre;//Layer指图层
                line1.LinetypeScale = 5 * scale;//指线性比例
                line1.Linetype = Linetype.Dashed;//Linetype指是点划线还是虚线什么的
                fun.PolyFill(dxf, polyline1, 0.5, contour);
                dxf.AddEntity(new EntityObject[] { line1 });
                Vector2[] pf = new Vector2[] { p1, p2, p3, p4, p0_1, p0_2 };
                return pf;
            }
            Vector2 p0 = new Vector2(0, 0);
            
           
            Vector2 p0_4 = new Vector2(0, -dconms * 3);
            Vector2[] pj1 = Noncutting(p0_4);
            Vector2 p1_1 = pj1[0];
            Vector2 p18 = fun.Polar(p1_1, 0, lh / 2.3);
            Vector2 p19_1 = fun.Polar(p1_1, 0, lh);
            Vector2 p19_2 = fun.Polar(p19_1, pi / 2, lh);
            Vector2 p19 = fun.Inters(p19_1, p19_2, p18, fun.Polar(p18, pi / -6, lh));
            Vector2 p20 = fun.Polar(p1_1, pi / -2, dconms - dconms * (0.32 / 6.18));
            Vector2 p21_1 = fun.Polar(p18, pi / -2, lh);
            Vector2 p21_2 = fun.Polar(p20, 0, lh);
            Vector2 p21 = fun.Inters(p20, p21_2, p18, p21_1);
            Vector2 p22 = new Vector2(lh - (oal - lf), -wf + p1_1.Y - dconms / 2.0);
            Vector2 p23_1 = fun.Polar(p19, pi, dconms * (0.32 / 6.18));
            Vector2 p23_2 = fun.Polar(p23_1, pi / -2, lh * 2);
            Vector2 p23 = fun.Inters(p23_1, p23_2, p22, fun.Polar(p22, pi - kapr_ - dp_ / 2, lh * 2));
            Vector2 p24 = fun.Polar(p22, pi - kapr_, (fun.CalDistance(p22, p23) / 2.0) / Math.Cos(pi / 6 / 2));
            Vector2 p25 = fun.Polar(p22, pi - kapr_ - dp_, fun.CalDistance(p22, p24));
            Vector2 p26 = fun.Polar(p25, fun.CalAngle(p25, p23), fun.CalDistance(p25, p23) / 5.0);
            Vector2 p27_0 = fun.Polar(p26, 40 * pi / 180, lh);
            Vector2 p27 = fun.Inters(p26, p27_0, p19, fun.Polar(p19, pi / -2, lf));
            Vector2 p28 = fun.Inters(p24, p23, p21, fun.Polar(p21, pi / -2, lh));
            Vector2 p29 = fun.Polar(p22, fun.CalAngle(p22, p23), fun.CalDistance(p22, p23) / 4.0);
            Vector2 p30 = fun.Polar(p24, fun.CalAngle(p24, p25), fun.CalDistance(p24, p25) / 4.0);
            Vector2 p31 = fun.Polar(p23, fun.CalAngle(p23, p22), fun.CalDistance(p22, p29));
            Vector2 p32 = fun.Polar(p25, fun.CalAngle(p25, p24), fun.CalDistance(p24, p30));
            Vector2 p33 = fun.Polar(p1_1, 0, fun.CalDistance(p1_1, p18) / 3.0);
            Vector2 p34 = fun.Polar(p20, 0, fun.CalDistance(p20, p21) / 4.0);
            Arc arc2 = fun.DrawArc5(p33, new Line(p1_1, p20), p34);
            var polyline3 = Pus.AddPointsToLwPolyLine(p20, p21, p28, p24, p22, p25, p23, p24, p22, p25, p26, p27, p19, p18, p1_1);
            var polyline4 = Pus.AddPointsToLwPolyLine(p29, p30, p31, p32, p29);
            /* dxf.AddEntity(new EntityObject[] { arc1,arc2
                 , polyline3 ,polyline4 
             });*/
            fun.PolyFill(dxf, polyline3, 0.5, contour);
            fun.PolyFill(dxf, polyline4, 0.5, contour);
            fun.drawBArc(dxf, arc2, 0.5, contour);
            //标注
            Vector2 v1 = fun.Polar(p0, pi, lpr - lh);
            Vector2 v2 = pj1[2];//2,p3
            Vector2 v3 = pj1[3];//2,p4
            Vector2 v4 = pj1[5];//2,p0_2
          
            fun.dimrot1(dxf, v2, v3, 90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "DCON", "", "");
            fun.dimrot1(dxf, p33, p19, 0, dconms / 2.0, 2, 1.2 * scale, 1.6 * scale, 0.9, "LH", "", "");
            fun.dimrot1(dxf, p1_1, p19, 0, dconms , 2, 1.2 * scale, 1.6 * scale, 0.9, "LDRED", "", "");
            fun.dimrot1(dxf, v4, p22, -90, dconms, 2, 1.2 * scale, 1.6 * scale, 0.9, "WF", "", "");
            fun.dimrot1(dxf, v3, p22, 180, dconms * 1.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "LF", "", "");
            fun.dimrot1(dxf, v3, p27, 180, dconms * 2.5, 2, 1.2 * scale, 1.6 * scale, 0.9, "OAL", "", "");
            fun.dimrot1(dxf, p22, p25, -145, dconms , 2, 1.2 * scale, 1.6 * scale, 0.9, "L", "", "");
            fun.jdbz2(dxf, new Line(p23, p24), new Line(p23, p25), dconms *3, 1.2 * scale, 1.6 * scale, 0.9, "EPSR", "", "");
            fun.jdbz2(dxf, new Line(p22, p24), new Line(p22, fun.Polar(p22, pi, 0.1)), wf / 2.0, 1.2 * scale, 1.6 * scale, 0.9, "KAPR", "", "");

            double isframe = Convert.ToInt32(data["isframe"]);
            String isframe_chose = Convert.ToString(data["isframe_chose"]);
            if (isframe == 1)
            {
                if (isframe_chose.Equals("0"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA0X(dxf, new Vector2(p0.X - 1189 / 2.0, p0.Y + 841 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("1"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA1X(dxf, new Vector2(p0.X - 841 / 2.0, p0.Y + 594 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("2"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA2X(dxf, new Vector2(p0.X - 594 / 2.0, p0.Y + 420 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("3"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA3X(dxf, new Vector2(p0.X - 420 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4X"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4X(dxf, new Vector2(p0.X - 297 / 2.0, p0.Y + 210 / 2.0 - 10 * 2.26), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }

                if (isframe_chose.Equals("4Y"))
                {
                    Dictionary<string, Vector2> position = Frame.frameA4Y(dxf, new Vector2(p0.X - 210 / 2.0, p0.Y + 297 / 2.0), data);
                    fun.writetext(dxf, scale + ":1", position["比例"], 3.5, 0, 0.6, "C");
                }
            }

            //定义格式，根据路径导出
            dxf.DrawingVariables.AcadVer = DxfVersion.AutoCad2007;
            dxf.Save(path);
        }
    }
}